from typing import List


class Solution:
    def maxArea(self, height: List[int]) -> int:
        head, tail, area= 0, len(height)-1, 0
        while head < tail:
            area = max(area, min(height[head], height[tail])*(tail - head))
            if height[head] < height[tail]:
                head += 1
            else:
                tail -= 1
        return area


height = [1, 8, 6, 2, 5, 4, 8, 3, 7]
print(Solution().maxArea(height))
height = [1,2,1]
print(Solution().maxArea(height))
height = [1, 1]
print(Solution().maxArea(height))
height = [4,3,2,1,4]
print(Solution().maxArea(height))